<?php

namespace app\admin\controller;

use think\Request;
use app\admin\service\SellerService;

class Seller extends Base
{
    /**
     * 商户列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $param = Request::instance()->param();
        $sellerService = new SellerService;
        $data = $sellerService->index($param);
        $this->assign('data',$data);
        return $this->fetch();
    }

    /**
     * 商户商品列表
    */
    public function sellerGoodsList()
    {
        $param = Request::instance()->param();
        $sellerService = new SellerService;
        $data = $sellerService->sellerGoodsList($param);
        $this->assign('data',$data);
        return $this->fetch();
    }

    /**
     * 商户申请列表
    */
    public function applys()
    {
        $param = Request::instance()->param();
        $sellerService = new SellerService;
        $data = $sellerService->applys($param);
        $this->assign('data',$data);
        return $this->fetch();
    }

    /**
     * 审核商户申请
    */
    public function examineApply()
    {
        if(Request::instance()->isPost()){
            $post = Request::instance()->post();
            $sellerService = new SellerService;
            return json($sellerService->examineApply($post));
        }
    }

    /**
     * 商户类型
    */
    public function sellerType()
    {
        $sellerService = new SellerService;
        $data = $sellerService->sellerType();
        $this->assign('data',$data);
        return $this->fetch();
    }

    /**
     * 新增商户类型
    */
    public function addSellerType()
    {
        if(Request::instance()->isGet()){
            return $this->fetch();
        }else{
            $post = Request::instance()->post();
            $sellerService = new SellerService;
            return json($sellerService->addSellerTypePost($post));
        }
    }

    /**
     * 编辑商户类型
    */
    public function editSellerType()
    {
        $sellerService = new SellerService;
        if(Request::instance()->isGet()){
            $id = input('id');
            $data = $sellerService->editSellerType($id);
            $this->assign('data',$data);
            return $this->fetch();
        }else{
            $post = Request::instance()->post();
            return json($sellerService->addSellerTypePost($post,2));
        }
    }

    /**
     * 删除商户类型
    */
    public function delSellerType()
    {
        if(Request::instance()->isPost()){
            $id = Request::instance()->post('id');
            $sellerService = new SellerService;
            return json($sellerService->delSellerType($id));
        }
    }

    /**
     * 充值列表
    */
    public function charge()
    {
        if(Request::instance()->isGet()){
            $sellerService = new SellerService;
            $param = Request::instance()->param();
            $data = $sellerService->charge($param);
            // dump($data);die;
            $this->assign('data',$data);
            return $this->fetch();
        }
    }

    /**
     * 查看打款截图
    */
    public function picture()
    {
        if(Request::instance()->isPost()){
            $id = Request::instance()->post('id');
            $sellerService = new SellerService;
            return json($sellerService->picture($id));
        }
    }

    /**
     * 审核放单人员充值
    */
    public function chargeExamine()
    {
        if(Request::instance()->isPost()){
            $sellerService = new SellerService;
            $post = Request::instance()->post();
            return json($sellerService->chargeExamine($post));
        }
    }
}
